<?php

namespace sample;

use \Fabula, \Gtk;

class frmConfigure {
	/**
	 * Armazena os widgets necessarios
	 * 
	 * @var array
	 */
	public $widgets = array();
	
	/**
	 * Construtor da classe
	 */
	public function __construct() {
		// Cria a janela
		$this->widgets['frmConfigure'] = Fabula::GtkWindow();
		$this->widgets['frmConfigure']->set_size_request(550, 350);
		$this->widgets['frmConfigure']->set_resizable(FALSE);
		$this->widgets['frmConfigure']->set_position(GTK::WIN_POS_CENTER);
		$this->widgets['frmConfigure']->set_title("Configurar");
		$box = Fabula::GtkVBox();
		
		$box->pack_start(Fabula::GtkLabel("Usuario"), FALSE);
		$box->pack_start(Fabula::GtkEntry(), FALSE);
		$box->pack_start(Fabula::GtkVBox(), TRUE);
		$box->pack_start($hbox = Fabula::GtkHBox(), FALSE);
		
		$hbox->pack_start(Fabula::GtkLabel(""), TRUE);
		$hbox->pack_start(Fabula::GtkButton("Confirmar", array($this, "onconfirm")), FALSE);
		$hbox->pack_start(Fabula::GtkButton("Cancelar", array($this, "oncancel")), FALSE);
		
		// Inicia a aplicação
		$this->widgets['frmConfigure']->connect("destroy", array($this, "frmConfigure_unload"));
		$this->widgets['frmConfigure']->add($box);
		$this->frmConfigure_onload();
	}
	
	/**
	 * Carrega formulario
	 */
	public function frmConfigure_onload() {
		$this->widgets['frmConfigure']->show_all();
	}
	
	/**
	 * Destroi o formulario
	 */
	public function frmConfigure_unload() {
		$this->widgets['frmConfigure']->destroy();
	}
	
	/**
	 * Botão de confirmar
	 */
	public function onconfirm() {
		echo "OK";
	}
	
	/**
	 * Botão de cancelar
	 */
	public function oncancel() {
		$this->frmConfigure_unload();
	}
}
